/*
 * scull_pipe.h  -- definetion for scull_pipe.c 
 * writed by wangxinyong, 2013/10/14
 * email: wxy8402@163.com.
 *
 */

#ifndef _SCULL_PIPE_H_
#define _SCULL_PIPE_H_

/*
 *Macros to help debugging
 */

#undef PDEBUG 
#ifdef PDEBUG
#ifdef __KERNEL__
#define  PDEBUG(fmt, args...) printk( KERN_DEBUG "scull: " fmt, ## args)
#else
#define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
#endif
#else  /* not define PDEBUG */
#define PDEBUG(fmt, args...)  /* not debugging: nothing */
#endif

#ifndef SCULL_MAJOR
#define SCULL_MAJOR 0   /* dynamic major by default */
#endif

#ifndef SCULL_P_NR_DEVS
#define SCULL_P_NR_DEVS 4  /* scullpipe0 through scullpipe3 */
#endif

/*
 * The pipeacc device is a simple circular buffer. Here its default size
 */
#ifndef SCULL_P_BUFFER
#define SCULL_P_BUFFER 4000
#endif

struct scull_pipe {
        wait_queue_head_t inq, outq;       /* read and write queues */
        char *buffer, *end;                /* begin of buf, end of buf */
        int buffersize;                    /* used in pointer arithmetic */
        char *rp, *wp;                     /* where to read, where to write */
        int nreaders, nwriters;            /* number of openings for r/w */
        struct semaphore sem;              /* mutual exclusion semaphore */
        struct cdev cdev;                  /* Char device structure */
};


#endif /* _SCULL_PIPE_H_ */

